<style></style>
<div>
  <textarea></textarea>
  <div></div>
  <textarea></textarea>
</div>
<div>promise look console</div>
<script src="./test.js"></script>
<script>
  console.warn('===))');
  //   const Pr = MyPromise;
  const Pr = Promise;

  function test1() {
    Pr.resolve(1).then((res) => console.log(res));
    Pr.reject(2).catch((e) => console.log('catch', e));
    Pr.reject(3)
      .then(() => console.log('then first'))
      .then((res) => console.log('then 22:', res))
      .catch((e) => console.log('catch after', e))
      .then((r) => {
        console.log('===', r);
        throw Pr.resolve(0);
      });
  }

  function test2() {
    const promise = Pr.resolve(0);
    promise
      .then(() => console.log(1))
      .then(() => console.log(1))
      .then(() => console.log(1));
    promise
      .then(() => console.log(2))
      .then(() => console.log(2))
      .then(() => console.log(2));
  }

  function test3() {
    let promise2 = new Pr((res, rej) => {
      throw new Error('test');
    });
    let promise = new Pr((res, rej) => {
      throw new Error('test');
    });
    promise.finally(() => {
      console.log('finally');
    });
  }

  function test4() {
    let promise = Pr.resolve(2);
    promise
      .finally(() => {
        console.log('finally');
      })
      .catch((e) => {
        console.log('catch');
      })
      .then((r) => {
        console.log('res,', r);
      });
  }

  //   test1();
  //   test2();
  //   test3();
  //   test4();

  let promise = Pr.reject(1);
  promise
    .then(
      (r) => {
        console.log('r', r);
        return 2;
      },
      (e) => {
        console.log('e', e);
        return 3;
      }
    )
    .then((r) => {
      console.log('after', r);
    });
</script>
脚本触发点击 和 用户实际点击 的区别：
<button id="x01">click me！</button> <button onclick="fnx02()">just trigger</button>
<script>
  const btn = document.getElementById('x01')
  btn.addEventListener('click', (e) => {
    Promise.resolve().then(() => {
      console.log('1,micro', e)
    })
    console.log(1)
  })
  btn.addEventListener('click', () => {
    Promise.resolve().then(() => {
      console.log('2,micro')
    })
    console.log(2)
  })

  function fnx02() {
    btn.click()
  }
</script>